package Aaaaaa;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main6 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int q = sc.nextInt();
        int[][] matrix = new int[m][3];
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < 3; j++) {
                matrix[i][j] = sc.nextInt();
            }
            String s1 = matrix[i][0] + "" + matrix[i][1] + "";
            String s2 = matrix[i][1] + "" + matrix[i][0] + "";
            map.put(s1, matrix[i][2]);
            map.put(s2, matrix[i][2]);

        }
        int[][] load = new int[q][2];
        for (int i = 0; i < q; i++) {
            for (int j = 0; j < 2; j++) {
                load[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < q; i++) {
            int a = load[i][0];
            int b = load[i][1];
            if (a == b || a <= 0 || a > n || b <= 0 || b > n) {
                System.out.println(0);
            } else if (a < b) {
                int max = 0;
                int cur = a;
                boolean flag = true;
                while (cur < b) {
                    String str = cur + "" + (cur + 1) + "";
                    cur++;
                    if (map.containsKey(str)) {
                        max = Math.max(max, map.get(str));
                    } else {
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    System.out.println(max);
                } else {
                    System.out.println(0);
                }
            } else {
                int max = 0;
                int cur = a;
                boolean flag = true;
                while (cur > b) {
                    String str = cur + "" + (cur + 1) + "";
                    cur--;
                    if (map.containsKey(str)) {
                        max = Math.max(max, map.get(str));
                    } else {
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    System.out.println(max);
                } else {
                    System.out.println(0);
                }
            }
        }
    }
}
